/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */

import {createNativeStackNavigator} from '@react-navigation/native-stack';
import React, {useEffect, useState} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {Provider as StoreProvider} from 'react-redux';
import {Text, View} from 'react-native';
import {persistor, store} from './app/store/store';
import {PersistGate} from 'redux-persist/integration/react';
import Home from './app/pages/home/services';
import Select from './app/pages/select/Select';
import Warm from './app/pages/warm/Warm';
import Learn from './app/pages/learn/Learn';
import Adventure from './app/pages/adventure/Adventure';
import Practise from './app/pages/practise/Practise';
import Select_adventure from './app/pages/select_adventure/Select_adventure';
import Login from './app/pages/login/Login';
import Report from './app/pages/report/Report';
import Contact from './app/pages/contact/Contact';
import Privacy from './app/pages/privacy/Privacy';
import Contract from './app/pages/contract/Contract';
import Awardshop from './app/pages/shop/Awardshop';
import Toolshop from './app/pages/shop/Toolshop';
import {
  RootSiblingsManager,
  RootSiblingParent,
  RootSiblingPortal,
} from 'react-native-root-siblings';
const Stack = createNativeStackNavigator();
function RootNavigation() {
  return (
    <Stack.Navigator>
      <Stack.Screen
        name="home"
        component={Home}
        options={{title: '', headerShown: false}}
        
      />
      <Stack.Screen
        name="select"
        component={Select}
        options={{title: '选择页面', headerShown: false}}
      />
      <Stack.Screen
        name="warm"
        component={Warm}
        initialParams={{unit: 'default'}}
        options={{title: '', headerShown: false}}
      />

      <Stack.Screen
        name="learn"
        component={Learn}
        options={{title: '学习页面', headerShown: false}}
      />

      <Stack.Screen
        name="practise"
        component={Practise}
        options={{title: '练习页面', headerShown: false}}
      />
      <Stack.Screen
        name="select_adventure"
        component={Select_adventure}
        options={{title: '冒险选择页面', headerShown: false}}
      />
      <Stack.Screen
        name="adventure"
        component={Adventure}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="login"
        component={Login}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="report"
        component={Report}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="contact"
        component={Contact}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="privacy"
        component={Privacy}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="contract"
        component={Contract}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="awardshop"
        component={Awardshop}
        options={{title: '', headerShown: false}}
      />
      <Stack.Screen
        name="toolshop"
        component={Toolshop}
        options={{title: '', headerShown: false}}
      />
    </Stack.Navigator>
  );
}
function App(): JSX.Element {
  const [splashFinished, setSplash] = useState(false);
  useEffect(() => {
    setTimeout(() => {
      setSplash(true);
    }, 2000);
  });
  return (
    <StoreProvider store={store}>
      <RootSiblingParent>
        <NavigationContainer>
          <PersistGate persistor={persistor}>
            {bootstrapped => {
              //加载逻辑进行判断
              if (bootstrapped && splashFinished) {
                return <RootNavigation />;
              } else {
                return (
                  <View>
                    <Text>欢迎</Text>
                  </View>
                );
              }
            }}
          </PersistGate>
        </NavigationContainer>
      </RootSiblingParent>
    </StoreProvider>
  );
}

export default App;
